//
//  HLVisitorTableViewController.swift
//  HL-sinaWeiBo
//
//  Created by 任翰林 on 16/5/11.
//  Copyright © 2016年 任翰林. All rights reserved.
//

import UIKit

class HLVisitorTableViewController: UITableViewController {

//    定义登录的标记
    var userLogin = HLUserAcountViewModel.shareUserAcountViewModel.isLogin
    
    var hlVisitorView = HLVisitorView()
    
    override func loadView() {
        if userLogin {
        super.loadView()
        
        } else {
            
 //            如果没有登录，我们需要自定义访客视图
            view = hlVisitorView
        
//            在这进行HLVisitorView两个按钮的点击事件的闭包回调
            hlVisitorView.callBackClosure = { [weak self] in
            
                print("我是HLVisitorView里面的按钮")
                        self?.requestOauthLogin()
            
            }
            
              setUpNavUi()
        
        }
        
        
    }
    
    
    //  MARK: - 设置导航栏左右注册登录按钮 -
    func setUpNavUi() {
    
//        navigationItem.leftBarButtonItem = UIBarButtonItem()
//        let regist = UIBarButtonItem()
//        
//        navBarItem.title = "注册"
////        navigationItem.leftBarButtonItem = UIBarButtonItem(customView: navBarItem)
//        navigationItem.leftBarButtonItem = navBarItem
        
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", fountSize: 15, target: self, action: "registerAction")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", fountSize: 15, target: self, action: "loginAction")
    
    
    }
    
    //  MARK: - UIBarButtonItem两个按钮的点击事件 -
   @objc func registerAction() {
    
    print("我是注册按钮，我被点击了")
            requestOauthLogin()
    }
    
   @objc func loginAction() {
    
    print("我是登录按钮，我被点击了")
        requestOauthLogin()
    
    }
    
    
        //  MARK: - 添加登录界面控制器里面的的方法 -
    func requestOauthLogin() {
    
    let oauthVC = HLOauthViewController()
        let nav = UINavigationController(rootViewController: oauthVC)
        presentViewController(nav, animated: true, completion: nil)
    
    
    
    }
    
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
//view.backgroundColor = UIColor.redColor()
    
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()

        
    }

    
    
    
    
}
